home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / bindings / modeori-fun / spec-fun < prev    next >
Encoding:
Text File  |  1996-09-27  |  49.3 KB  |  1,841 lines

  1. ;OCL{{{}}}
  2. ;OCL{{{  shell-mode
  3. @if-using ( SHELL-MODE )
  4.    ;OCL{{{  variables
  5.    ( defvar
  6.       ( I-op
  7.         I-menu-xwin
  8.         I-xwin
  9.         I-ywin
  10.         I-entered-filed
  11.         I-hash
  12.         I-arg-file-set
  13.         I-selected
  14.         I-help
  15.         I-edit-extern
  16.       )
  17.    )
  18.    ( history I-arg-file )
  19.    ( history I-file-source )
  20.    ( history I-menu-directory )
  21.    ;OCL}}}
  22.    ;OCL{{{  switch to editor
  23.    ;OCL{{{  variables
  24.    ( defvar
  25.       ( shell-mode-re
  26.         shell-mode-delay
  27.         shell-mode-pos
  28.         shell-mode-over
  29.       )
  30.    )
  31.    ;OCL}}}
  32.    ;OCL{{{  begin-modeori
  33.    ( deffun begin-modeori
  34.       ( set shell-mode-active false
  35.         screen-off
  36.         ;OCL{{{  overwrite
  37.         if shell-mode-over ( add-mode-overwrite ) fi
  38.         ;OCL}}}
  39.         ;OCL{{{  statusline
  40.         if not(status-line) ( status-line-off ) fi
  41.         ;OCL}}}
  42.         ;OCL{{{  regular expression
  43.         case
  44.          ( =(2 shell-mode-re) ( add-mode-extended-regular-expression ) )
  45.          ( =(1 shell-mode-re) ( add-mode-basic-regular-expression ) )
  46.         esac
  47.         ;OCL}}}
  48.         ;OCL{{{  autosave
  49.         if shell-mode-delay
  50.          ( set modify-behaviour shell-mode-delay
  51.            add-mode-autosave
  52.            set modify-behaviour 0
  53.          )
  54.         fi
  55.         ;OCL}}}
  56.         ;OCL{{{  position
  57.         if shell-mode-pos ( add-mode-position ) fi
  58.         ;OCL}}}
  59.         ;OCL{{{  autolanguage
  60.         if auto-language
  61.          ( set-user-mode AL )
  62.         fi
  63.         ;OCL}}}
  64.         ;OCL{{{  edit
  65.         set-user-mode ED
  66.         ;OCL}}}
  67.         ;OCL{{{  raw
  68.         if =(extended-version 0)
  69.          ( set-user-mode NOEX )
  70.         fi
  71.         ;OCL}}}
  72.         ;OCL{{{  extended
  73.         @if-using ( L-EXT )
  74.            if >(extended-version 0)
  75.             ( set-user-mode LEXT )
  76.            fi
  77.         @fi
  78.         ;OCL}}}
  79.         ;OCL{{{  screen-based
  80.         if stepping
  81.          ( set-user-mode STEP )
  82.         fi
  83.         ;OCL}}}
  84.         ;OCL{{{  auto-indent
  85.         if auto-indent
  86.          ( set-user-mode AI )
  87.         fi
  88.         ;OCL}}}
  89.         ;OCL{{{  buffer-save
  90.         if buff-saving ( reset-user-mode BS ) fi
  91.         ;OCL}}}
  92.         ;OCL{{{  EDT
  93.         @if-using ( SUNEDT )
  94.            if EDT-used
  95.             ( set-user-mode EDT-TAG
  96.               ;OCL{{{  backup
  97.               if EDT-move-back
  98.                ( reset-user-mode EDT-backup )
  99.               fi
  100.               ;OCL}}}
  101.             )
  102.            fi
  103.         @fi
  104.         ;OCL}}}
  105.         screen-on
  106.         redraw-display
  107.         edit
  108.         read-newfile-macro
  109.       )
  110.    )
  111.    ;OCL}}}
  112.    ;OCL{{{  end-modeori
  113.    ( deffun end-modeori
  114.       ( set shell-mode-active true
  115.         screen-off
  116.         ;OCL{{{  overwrite
  117.         set shell-mode-over false
  118.         if test-overwrite
  119.          ( set shell-mode-over true
  120.            delete-mode-overwrite
  121.          )
  122.         fi
  123.         ;OCL}}}
  124.         ;OCL{{{  statusline
  125.         status-line-on
  126.         ;OCL}}}
  127.         ;OCL{{{  regular expression
  128.         delete-mode-regular-expression
  129.         set shell-mode-re ocl-argument
  130.         ;OCL}}}
  131.         ;OCL{{{  autosave
  132.         delete-mode-autosave
  133.         set shell-mode-delay ocl-argument
  134.         ;OCL}}}
  135.         ;OCL{{{  position
  136.         set shell-mode-pos show-position
  137.         delete-mode-position
  138.         ;OCL}}}
  139.         ;OCL{{{  autolanguage
  140.         reset-user-mode AL
  141.         ;OCL}}}
  142.         ;OCL{{{  edit
  143.         reset-user-mode ED
  144.         ;OCL}}}
  145.         ;OCL{{{  extended/raw
  146.         reset-user-mode NOEX
  147.         @if-using ( L-EXT )
  148.            reset-user-mode LEXT
  149.         @fi
  150.         ;OCL}}}
  151.         ;OCL{{{  screen-based
  152.         reset-user-mode STEP
  153.         ;OCL}}}
  154.         ;OCL{{{  auto-indent
  155.         reset-user-mode AI
  156.         ;OCL}}}
  157.         ;OCL{{{  buffer-save
  158.         reset-user-mode BS
  159.         ;OCL}}}
  160.         ;OCL{{{  EDT
  161.         @if-using ( SUNEDT )
  162.            reset-user-mode EDT-TAG
  163.            reset-user-mode EDT-backup
  164.         @fi
  165.         ;OCL}}}
  166.         screen-on
  167.         redraw-display
  168.       )
  169.    )
  170.    ;OCL}}}
  171.    ;OCL{{{  undeclares
  172.    ( undeclare
  173.       ( shell-mode-re
  174.         shell-mode-delay
  175.         shell-mode-pos
  176.         shell-mode-over
  177.       )
  178.    )
  179.    ;OCL}}}
  180.    ;OCL}}}
  181.    ;OCL{{{  macros
  182.    ;OCL{{{  I-go-mouse
  183.    ( deffun I-go-mouse
  184.       ( if not(mouse-outside)
  185.          ( while >(mouse-go-y 0)
  186.             ( next-line
  187.               set mouse-go-y -(mouse-go-y 1)
  188.             )
  189.            while <>(mouse-go-y 0)
  190.             ( previous-line
  191.               set mouse-go-y +(mouse-go-y 1)
  192.             )
  193.          )
  194.         fi
  195.       )
  196.    )
  197.    ;OCL}}}
  198.    ;OCL{{{  add-mode-shell
  199.    ( demand-load (
  200.       ( deffun add-mode-shell
  201.          ( if not(ocl-arg-field(15))
  202.             ( set ocl-arg-field(15) -1
  203.               screen-off
  204.               history-edit I-menu-directory ()
  205.                  default-menu-file
  206.                  newline-and-indent
  207.               screen-on
  208.               set I-op 1
  209.               set-user-mode I-XS-EDIT
  210.               message ( "[ModeOriShell "  "active] )
  211.             )
  212.            fi
  213.          )
  214.       )
  215.    ) )
  216.    ;OCL}}}
  217.    ;OCL{{{  menu sub functions
  218.    ;OCL{{{  I-clear-user-modes
  219.    ( deffun I-clear-user-modes
  220.       ( reset-user-mode I-XS-MAIN
  221.         reset-user-mode I-XS-FILE
  222.         reset-user-mode I-XS-EDIT
  223.         reset-user-mode I-XS-BROWSE
  224.       )
  225.    )
  226.    ;OCL}}}
  227.    ;OCL{{{  I-history-edit-filename
  228.    ( deffun I-history-edit-filename
  229.       ( screen-off
  230.         history-edit-line I-arg-file ()
  231.            ;OCL{{{  move to start of filename, maybe strip long info
  232.            end-of-line
  233.            do
  234.             ( backward-character )
  235.            while not(or(test-char-set space test-begin-line))
  236.            if test-char-set space
  237.             ( forward-character )
  238.            fi
  239.            while not(test-begin-line)
  240.             ( raw-delete-previous-character )
  241.            ;OCL}}}
  242.            if not(test-char path-separator)
  243.             ;OCL{{{  get leading path
  244.             ( get-history I-menu-directory 0
  245.               if test-begin-line
  246.                ( default-menu-file )
  247.               fi
  248.               insert-ascii path-separator
  249.             )
  250.             ;OCL}}}
  251.            fi
  252.            beginning-of-line
  253.            ;OCL{{{  maybe replace leading ~/ by $HOME/
  254.            if
  255.               and
  256.                ( test-char "~
  257.                  pre ( forward-character ) test-char path-separator
  258.                )
  259.             ( delete-previous-character
  260.               "$HOME
  261.             )
  262.            fi
  263.            ;OCL}}}
  264.            ;OCL{{{  maybe cut dir/.. sequences
  265.            end-of-line
  266.            while not(test-begin-line)
  267.             ( if
  268.                ;OCL{{{  /.. found
  269.                  and
  270.                   ( pre
  271.                      ( backward-character )
  272.                        and(not(test-begin-line) test-char ".)
  273.                     pre
  274.                      ( backward-character )
  275.                        and(not(test-begin-line) test-char ".)
  276.                     pre
  277.                      ( backward-character )
  278.                        and(not(test-begin-line) test-char path-separator)
  279.                   )
  280.                ;OCL}}}
  281.                ;OCL{{{  check and do the dir/.. remove
  282.                (
  283.                  ;OCL{{{  skip /
  284.                  do
  285.                   ( backward-character )
  286.                  while and(not(test-begin-line) test-char path-separator)
  287.                  ;OCL}}}
  288.                  ;OCL{{{  skip dir name
  289.                  do
  290.                   ( backward-character )
  291.                  while
  292.                     and
  293.                      ( not(test-begin-line)
  294.                        not(test-char path-separator)
  295.                        not(test-char ". )
  296.                      )
  297.                  ;OCL}}}
  298.                  if test-char path-separator
  299.                   ;OCL{{{  remove dir/.. from name!
  300.                   ( do
  301.                      ( delete-character )
  302.                     while not(test-char path-separator)
  303.                     do
  304.                      ( delete-character )
  305.                     while test-char path-separator
  306.                     delete-character
  307.                     delete-character
  308.                     end-of-line
  309.                     if test-begin-line
  310.                      ( insert-ascii path-separator )
  311.                     fi
  312.                   )
  313.                   ;OCL}}}
  314.                  fi
  315.                )
  316.                ;OCL}}}
  317.               fi
  318.             )
  319.            ;OCL}}}
  320.            newline-and-indent
  321.         set I-arg-file-set true
  322.         screen-on
  323.       )
  324.    )
  325.    ;OCL}}}
  326.    ;OCL{{{  I-check-arg
  327.    ( deffun  I-check-arg
  328.       ( set I-arg-file-set false
  329.         if I-selected
  330.          ;OCL{{{  get selected file
  331.          ( beginning-of-fold
  332.            while not(test-bottom)
  333.             ( if
  334.                ;OCL{{{  selected file
  335.                  and
  336.                   ( test-filed
  337.                     pre ( goto 6 ) test-str ( "  "* "  )
  338.                   )
  339.                ;OCL}}}
  340.                ;OCL{{{  get file from dir/line
  341.                ( I-history-edit-filename
  342.                  end-of-fold
  343.                )
  344.                ;OCL}}}
  345.               else
  346.                ;OCL{{{  try next line
  347.                ( open-fold
  348.                  next-line
  349.                )
  350.                ;OCL}}}
  351.               fi
  352.             )
  353.            beginning-of-line
  354.          )
  355.          ;OCL}}}
  356.         fi
  357.       )
  358.    )
  359.    ;OCL}}}
  360.    ( demand-load (
  361.       ;OCL{{{  I-prompt-for-file
  362.       ( deffun ( p ) I-prompt-for-file
  363.          ( case
  364.             (                  =(p 0) ( history-edit I-arg-file "Directory ) )
  365.             ( pre(set p -(p 1))=(p 0) ( history-edit I-arg-file "Source-File ) )
  366.             ( pre(set p -(p 1))=(p 0) ( history-edit I-arg-file "Destination-File ) )
  367.            default
  368.             ( history-edit I-arg-file "File )
  369.            esac
  370.            do
  371.             ( begin-prompt-macro
  372.               prompt-char-counter I-help ()
  373.               end-prompt-macro
  374.               if =(I-help newline-and-indent)
  375.                ;OCL{{{  add current path and maybe use default
  376.                ( end-of-line
  377.                  if test-begin-line
  378.                   ( if <(p 0)
  379.                      ( default-edit-file )
  380.                     else
  381.                      ( default-menu-file )
  382.                     fi
  383.                   )
  384.                  else
  385.                   ( beginning-of-line
  386.                     if and(not(test-char path-separator) not(test-char "~))
  387.                      ( get-history I-menu-directory 0
  388.                        if test-begin-line
  389.                         ( default-menu-file )
  390.                        fi
  391.                        insert-ascii path-separator
  392.                      )
  393.                     fi
  394.                   )
  395.                  fi
  396.                  end-of-line
  397.                )
  398.                ;OCL}}}
  399.               fi
  400.               insert-ascii I-help
  401.             )
  402.            while <>(I-help newline-and-indent)
  403.            set I-arg-file-set true
  404.          )
  405.       )
  406.       ;OCL}}}
  407.    ) )
  408.    ;OCL{{{  I-center-xoff
  409.    ( deffun I-center-xoff
  410.       ( set I-xwin +(div(-(screen-width I-xwin) 2) 1)
  411.         if <=(I-xwin 0) ( set I-xwin 1 ) fi
  412.       )
  413.    )
  414.    ;OCL}}}
  415.    ;OCL{{{  I-default-win
  416.    ( deffun I-default-win
  417.       ( I-clear-user-modes
  418.         if >(ocl-arg-field(15) 0)
  419.          ( if >(screen-height 10)
  420.             ;OCL{{{  use window and return
  421.             ( screen-off
  422.               set-area 5
  423.               ;OCL{{{  write centered mode name
  424.               set I-ywin 2
  425.               set I-xwin 22
  426.               I-center-xoff
  427.               set I-menu-xwin +(I-xwin 13)
  428.               write-area I-xwin I-ywin ( "ModeOriShell- )
  429.               ;OCL}}}
  430.               ;OCL{{{  write ( ? for list of keys ) at left border
  431.               set I-xwin 8
  432.               set I-ywin 5
  433.               write-area I-xwin I-ywin ( "( "  "? "  "for "  "list "  "of "  "keys "  ") )
  434.               ;OCL}}}
  435.               ;OCL{{{  write ( i for info ) at right border
  436.               @if-using not( NO-HELP-BROWSER )
  437.                  set I-xwin -(screen-width 20)
  438.                  if <=(I-xwin 32)
  439.                   ( set I-xwin 32 )
  440.                  fi
  441.                  write-area I-xwin I-ywin ( "( "  "i "  "for "  "info "  ") )
  442.               @fi
  443.               ;OCL}}}
  444.               ;OCL{{{  write space at end of line to force inverse line!
  445.               set I-xwin +(I-xwin screen-width)
  446.               write-area I-xwin I-ywin ( "  )
  447.               ;OCL}}}
  448.               screen-on
  449.               redraw-display
  450.               return-from-macro
  451.             )
  452.             ;OCL}}}
  453.            fi
  454.            set ocl-arg-field(15) -1
  455.          )
  456.         fi
  457.         ;OCL{{{  use modes
  458.         set-area 0
  459.         ;OCL}}}
  460.       )
  461.    )
  462.    ;OCL}}}
  463.    ;OCL}}}
  464.    ;OCL{{{  main-menu
  465.    ;OCL{{{  I-main-area
  466.    ( deffun I-main-area
  467.       ( I-default-win
  468.         if >(ocl-arg-field(15) 0)
  469.          ;OCL{{{  write in window
  470.          ( set I-ywin 2
  471.            write-area I-menu-xwin I-ywin ( "Main-Menu )
  472.            set I-ywin 3
  473.            set I-xwin 65
  474.            I-center-xoff
  475.            write-area I-xwin I-ywin
  476.             (       "Directory
  477.               "  "  "Browser
  478.               "  "  "File
  479.               "  "  "Edit
  480.               "  "  "Select
  481.               "  "  "Make
  482.               "  "  "Postbox
  483.               "  "  "News
  484.               "  "  "Quit
  485.             )
  486.          )
  487.          ;OCL}}}
  488.         else
  489.          ;OCL{{{  use modes
  490.          ( set-user-mode I-XS-MAIN )
  491.          ;OCL}}}
  492.         fi
  493.       )
  494.    )
  495.    ;OCL}}}
  496.    ;OCL{{{  I-quit-shell
  497.    ( deffun I-quit-shell
  498.       ( while true
  499.          ( set-file-unchanged
  500.            exit-buffer
  501.          )
  502.       )
  503.    )
  504.    ;OCL}}}
  505.    ;OCL{{{  I-start-main
  506.    ( defmac I-start-main
  507.       (
  508.         ;OCL{{{  get current menu file
  509.         read-file
  510.            get-history I-menu-directory 0
  511.            if test-begin-line
  512.             ( default-menu-file )
  513.            fi
  514.            newline-and-indent
  515.         history-edit-filename I-menu-directory ()
  516.            newline-and-indent
  517.         goto 1
  518.         ;OCL}}}
  519.         ;OCL{{{  set modes
  520.         set I-selected 0
  521.         delete-mode-view
  522.         delete-mode-hash-shift
  523.         set-file-unchanged
  524.         I-Main-Menu
  525.         ;OCL}}}
  526.         I-main-area
  527.       )
  528.    )
  529.    ;OCL}}}
  530.    ;OCL{{{  I-re-enter-main
  531.    ( deffun I-re-enter-main
  532.      ( I-Main-Menu
  533.        I-main-area
  534.        set I-op 0
  535.      )
  536.    )
  537.    ;OCL}}}
  538.    ;OCL{{{  I-main-reread
  539.    ( deffun I-main-reread
  540.       ( set I-selected 0
  541.         read-file
  542.            get-history I-menu-directory 0
  543.            if test-begin-line
  544.             ( default-menu-file )
  545.            fi
  546.            newline-and-indent
  547.         goto 1
  548.         delete-mode-view
  549.         delete-mode-hash-shift
  550.         set-file-unchanged
  551.       )
  552.    )
  553.    ;OCL}}}
  554.    ;OCL{{{  I-change-commands
  555.    ( deffun I-change-commands
  556.       ( command-para-menu
  557.         I-Main-Menu
  558.       )
  559.    )
  560.    ;OCL}}}
  561.    ( demand-load (
  562.       ;OCL{{{  I-msg-extern-edit
  563.       ( deffun I-msg-extern-edit
  564.          ( message ( "[ "starting "  history I-edit-cmd "] ) )
  565.       )
  566.       ;OCL}}}
  567.       ;OCL{{{  I-refresh-directory
  568.       ( deffun I-refresh-directory
  569.          ( screen-off
  570.            I-re-enter-main
  571.            I-main-reread
  572.            screen-on
  573.            center-and-redraw-display
  574.          )
  575.       )
  576.       ;OCL}}}
  577.       ;OCL{{{  I-change-directory
  578.       ( deffun I-change-directory
  579.          ( screen-off
  580.            I-check-arg
  581.            if not(I-arg-file-set)
  582.             ( screen-on
  583.               redraw-display
  584.               I-prompt-for-file(0)
  585.               screen-off
  586.             )
  587.            fi
  588.            ;OCL{{{  get directory
  589.            read-file
  590.               get-history I-arg-file 0
  591.               newline-and-indent
  592.            ;OCL}}}
  593.            set I-selected 0
  594.            ;OCL{{{  check dir and restore screen
  595.            if >(file-type 0)
  596.             ;OCL{{{  store name
  597.             ( history-edit-filename I-menu-directory ()
  598.                  newline-and-indent
  599.               screen-on
  600.               redraw-display
  601.             )
  602.             ;OCL}}}
  603.            else
  604.             ;OCL{{{  restore old and complain
  605.             ( I-main-reread
  606.               screen-on
  607.               redraw-display
  608.               message ( "[ "No "  "such "  "directory "] )
  609.             )
  610.             ;OCL}}}
  611.            fi
  612.            ;OCL}}}
  613.            delete-mode-view
  614.            delete-mode-hash-shift
  615.            set-file-unchanged
  616.          )
  617.       )
  618.       ;OCL}}}
  619.       ;OCL{{{  I-edit
  620.       ( deffun I-edit
  621.          (
  622.            ;OCL{{{  get edit file (from selection or prompt)
  623.            screen-off
  624.            I-check-arg
  625.            screen-on
  626.            if not(I-arg-file-set)
  627.             ( redraw-display
  628.               I-prompt-for-file(-1)
  629.             )
  630.            fi
  631.            ;OCL}}}
  632.            if I-edit-extern
  633.             ;OCL{{{  call external editor
  634.             ( I-msg-extern-edit
  635.               screen-off
  636.               local
  637.                ( force-bourne-shell )
  638.                ( set force-bourne-shell true
  639.                  shell-command
  640.                     cd-cmd "  ;
  641.                     get-history I-menu-directory 0
  642.                     cmd-separator
  643.                     get-history I-edit-cmd 0
  644.                     "  ;
  645.                     get-history I-arg-file 0
  646.                     newline-and-indent
  647.                )
  648.               newline-and-indent
  649.               screen-on
  650.               I-main-reread
  651.             )
  652.             ;OCL}}}
  653.            else
  654.             ;OCL{{{  switch to edit
  655.             ( set I-op 1
  656.               read-file
  657.                  get-history I-arg-file 0
  658.                  newline-and-indent
  659.               redraw-display
  660.               end-shell-mode
  661.               message ( history error-list )
  662.             )
  663.             ;OCL}}}
  664.            fi
  665.          )
  666.       )
  667.       ;OCL}}}
  668.       ;OCL{{{  I-call-cmd
  669.       ( deffun ( cmd ) I-call-cmd
  670.          ( local
  671.             ( force-bourne-shell )
  672.             ( set force-bourne-shell true
  673.               shell-command
  674.                  get-history I-menu-directory 0
  675.                  if test-begin-line
  676.                   ( default-menu-file )
  677.                  fi
  678.                  cmd-separator
  679.                  insert-ascii cmd
  680.                  beginning-of-line
  681.                  cd-cmd "  ;
  682.                  newline-and-indent
  683.             )
  684.            newline-and-indent
  685.            if ocl-argument
  686.             ( failed )
  687.            fi
  688.          )
  689.       )
  690.       ;OCL}}}
  691.       ;OCL{{{  I-make
  692.       ;OCL{{{  I-get-make-cmd
  693.       ( deffun I-get-make-cmd ( get-history make-cmd-hist 0 ) )
  694.       ;OCL}}}
  695.  
  696.       ( deffun I-make ( I-call-cmd(I-get-make-cmd) ) )
  697.       ;OCL}}}
  698.       ;OCL{{{  I-mail
  699.       ;OCL{{{  I-get-mail-cmd
  700.       ( deffun I-get-mail-cmd ( get-history mail-cmd-hist 0 ) )
  701.       ;OCL}}}
  702.  
  703.       ( deffun I-mail ( I-call-cmd(I-get-mail-cmd) ) )
  704.       ;OCL}}}
  705.       ;OCL{{{  I-nn
  706.       ;OCL{{{  I-get-nn-cmd
  707.       ( deffun I-get-nn-cmd ( get-history I-nn-cmd 0 ) )
  708.       ;OCL}}}
  709.  
  710.       ( deffun I-nn ( I-call-cmd(I-get-nn-cmd) ) )
  711.       ;OCL}}}
  712.       ;OCL{{{  I-open-fold
  713.       ( defmac I-open-fold ( open-fold ) )
  714.       ;OCL}}}
  715.       ;OCL{{{  I-close-fold
  716.       ( defmac I-close-fold ( close-fold ) )
  717.       ;OCL}}}
  718.       ;OCL{{{  I-toggle-select
  719.       ( deffun I-toggle-select
  720.          ( if test-filed
  721.             ;OCL{{{  toggle the selection
  722.             ( forward-character
  723.               forward-character
  724.               forward-character
  725.               forward-character
  726.               forward-character
  727.               if test-char "  ;
  728.                ( delete-character delete-character delete-character
  729.                  set I-selected -(I-selected 1)
  730.                )
  731.               else
  732.                ( "  "* "  ;
  733.                  set I-selected +(I-selected 1)
  734.                )
  735.               fi
  736.               beginning-of-line
  737.               set-file-unchanged
  738.             )
  739.             ;OCL}}}
  740.            fi
  741.            I-open-fold
  742.            next-line
  743.            message ( counter I-selected "  "files "  "selected )
  744.          )
  745.       )
  746.       ;OCL}}}
  747.       ;OCL{{{  I-action-select
  748.       ( deffun I-action-select
  749.          ( if test-filed
  750.             ( screen-off
  751.               I-history-edit-filename
  752.               read-file
  753.                  get-history I-arg-file 0
  754.                  newline-and-indent
  755.               if =(file-type 0)
  756.                ;OCL{{{  edit the file
  757.                ( if I-edit-extern
  758.                   ;OCL{{{  call external editor
  759.                   ( I-msg-extern-edit
  760.                     screen-off
  761.                     local
  762.                      ( force-bourne-shell )
  763.                      ( set force-bourne-shell true
  764.                        shell-command
  765.                           get-history I-edit-cmd 0
  766.                           "  ;
  767.                           get-history I-arg-file 0
  768.                           newline-and-indent
  769.                      )
  770.                     newline-and-indent
  771.                     screen-on
  772.                     I-main-reread
  773.                   )
  774.                   ;OCL}}}
  775.                  else
  776.                   ;OCL{{{  switch to edit
  777.                   ( set I-op 1
  778.                     screen-on
  779.                     redraw-display
  780.                     end-shell-mode
  781.                   )
  782.                   ;OCL}}}
  783.                  fi
  784.                )
  785.                ;OCL}}}
  786.               else
  787.                ;OCL{{{  continue shell-mode
  788.                ( set I-selected 0
  789.                  history-edit-filename I-menu-directory ()
  790.                     newline-and-indent
  791.                  screen-on
  792.                  redraw-display
  793.                  delete-mode-view
  794.                  delete-mode-hash-shift
  795.                  set-file-unchanged
  796.                )
  797.                ;OCL}}}
  798.               fi
  799.             )
  800.            else
  801.             ( I-open-fold
  802.               next-line
  803.             )
  804.            fi
  805.          )
  806.       )
  807.       ;OCL}}}
  808.       ;OCL{{{  I-toggle-expert-mode
  809.       ( deffun I-toggle-expert-mode
  810.          ( set ocl-arg-field(15) -ocl-arg-field(15)
  811.            I-main-area
  812.          )
  813.       )
  814.       ;OCL}}}
  815.    ) )
  816.    ;OCL}}}
  817.    ;OCL{{{  file-menu
  818.    ( demand-load (
  819.       ;OCL{{{  I-file-area
  820.       ( defmac I-file-area
  821.          ( I-default-win
  822.            if >(ocl-arg-field(15) 0)
  823.             ;OCL{{{  use win
  824.             ( set I-ywin 2
  825.               write-area I-menu-xwin I-ywin ( "File-Menu )
  826.               set I-xwin 24
  827.               I-center-xoff
  828.               set I-ywin 3
  829.               write-area I-xwin I-ywin ( "Copy "  "  "Move "  "  "Remove "  "  "Quit )
  830.             )
  831.             ;OCL}}}
  832.            else
  833.             ;OCL{{{  use mode
  834.             ( set-user-mode I-XS-FILE )
  835.             ;OCL}}}
  836.            fi
  837.          )
  838.       )
  839.       ;OCL}}}
  840.       ;OCL{{{  I-file-menu
  841.       ( deffun I-file-menu
  842.          ( I-File-Menu
  843.            I-file-area
  844.            set I-op 2
  845.          )
  846.       )
  847.       ;OCL}}}
  848.       ;OCL{{{  I-quit-file-menu
  849.       ( deffun I-quit-file-menu ( I-re-enter-main ) )
  850.       ;OCL}}}
  851.       ;OCL{{{  I-remove-file
  852.       ;OCL{{{  prompt-file-remove
  853.       ( defmac prompt-file-remove
  854.          ( screen-off
  855.            history-edit string-buffer ()
  856.               "remove "  "file "  get-history I-arg-file 0
  857.               newline-and-indent
  858.            screen-on
  859.            set I-help eval ( yes-no-menu(false) )
  860.          )
  861.       )
  862.       ;OCL}}}
  863.  
  864.       ( deffun I-remove-file
  865.          ( if not(I-selected)
  866.             ;OCL{{{  prompt for file and do it
  867.             ( I-prompt-for-file(1)
  868.               prompt-file-remove
  869.               if I-help
  870.                ( local
  871.                   ( force-bourne-shell )
  872.                   ( set force-bourne-shell true
  873.                     shell-command
  874.                        rm-cmd
  875.                        "  get-history I-arg-file 0
  876.                        newline-and-indent
  877.                        set I-help ocl-argument
  878.                   )
  879.                )
  880.               fi
  881.             )
  882.             ;OCL}}}
  883.            else
  884.             ;OCL{{{  remove selected files
  885.             ( beginning-of-fold
  886.               do
  887.                ( if
  888.                   ;OCL{{{  selected line
  889.                     and
  890.                      ( pre
  891.                         ( search-forward "...F "  "  "* "  newline-and-indent )
  892.                           test-filed
  893.                        pre
  894.                         ( goto 6 )
  895.                           test-str ( "  "* "  )
  896.                      )
  897.                   ;OCL}}}
  898.                   ;OCL{{{  remove and save exit
  899.                   ( screen-off
  900.                     I-history-edit-filename
  901.                     screen-on
  902.                     prompt-file-remove
  903.                     if I-help
  904.                      ( local
  905.                         ( force-bourne-shell )
  906.                         ( set force-bourne-shell true
  907.                           shell-command
  908.                              rm-cmd
  909.                              "  get-history I-arg-file 0
  910.                              newline-and-indent
  911.                         )
  912.                        newline-and-indent
  913.                        set I-help ocl-argument
  914.                      )
  915.                     fi
  916.                     next-line
  917.                     beginning-of-line
  918.                   )
  919.                   ;OCL}}}
  920.                  else
  921.                   ;OCL{{{  end
  922.                   ( set I-help -1 )
  923.                   ;OCL}}}
  924.                  fi
  925.                )
  926.               while not(I-help)
  927.             )
  928.             ;OCL}}}
  929.            fi
  930.            I-main-reread
  931.            message ()
  932.            if >(I-help 0)
  933.             ( message ( "[failed "  "for "  history I-arg-file "] ) )
  934.            fi
  935.          )
  936.       )
  937.       ( undeclare ( prompt-file-remove ) )
  938.       ;OCL}}}
  939.       ;OCL{{{  I-copy-or-move-file
  940.       ( deffun ( op ) I-copy-or-move-file
  941.          ( if not(I-selected)
  942.             ;OCL{{{  prompt for file
  943.             ( I-prompt-for-file(1)
  944.               screen-off
  945.               history-edit I-file-source ()
  946.                  get-history I-arg-file 0
  947.                  newline-and-indent
  948.               screen-on
  949.             )
  950.             ;OCL}}}
  951.            fi
  952.            I-prompt-for-file(2)
  953.            screen-off
  954.            set I-help 0
  955.            if I-selected
  956.             ;OCL{{{  copy/move selected files
  957.             (
  958.               ;OCL{{{  save destination
  959.               history-edit I-file-source ()
  960.                  get-history I-arg-file 0
  961.                  newline-and-indent
  962.               ;OCL}}}
  963.               beginning-of-fold
  964.               do
  965.                ( if
  966.                   ;OCL{{{  selected line
  967.                     and
  968.                      ( test-filed
  969.                        pre ( goto 6 ) test-str ( "  "* "  )
  970.                      )
  971.                   ;OCL}}}
  972.                   ;OCL{{{  copy/move and save exit
  973.                   ( I-history-edit-filename
  974.                     local
  975.                      ( force-bourne-shell )
  976.                      ( set force-bourne-shell true
  977.                        shell-command
  978.                           if op ( cp-cmd ) else ( mv-cmd ) fi
  979.                           "  get-history I-arg-file 0
  980.                           "  get-history I-file-source 0
  981.                           newline-and-indent
  982.                      )
  983.                     newline-and-indent
  984.                     set I-help ocl-argument
  985.                   )
  986.                   ;OCL}}}
  987.                  fi
  988.                  I-open-fold
  989.                  next-line
  990.                )
  991.               while and(not(test-bottom) not(I-help))
  992.             )
  993.             ;OCL}}}
  994.            else
  995.             ;OCL{{{  copy/move entered file
  996.             ( local
  997.                ( force-bourne-shell )
  998.                ( set force-bourne-shell true
  999.                  shell-command
  1000.                     if op ( cp-cmd ) else ( mv-cmd ) fi
  1001.                     "  get-history I-file-source 0
  1002.                     "  get-history I-arg-file 0
  1003.                     newline-and-indent
  1004.                )
  1005.               newline-and-indent
  1006.             )
  1007.             ;OCL}}}
  1008.            fi
  1009.            I-main-reread
  1010.            screen-on
  1011.            redraw-display
  1012.            message ()
  1013.            if I-help
  1014.             ( message ( "[failed "  "for "  history I-arg-file "] ) )
  1015.            fi
  1016.          )
  1017.       )
  1018.       ;OCL}}}
  1019.       ;OCL{{{  I-copy-file
  1020.       ( deffun I-copy-file ( I-copy-or-move-file(true) ) )
  1021.       ;OCL}}}
  1022.       ;OCL{{{  I-move-file
  1023.       ( deffun I-move-file ( I-copy-or-move-file(false) ) )
  1024.       ;OCL}}}
  1025.    ) )
  1026.    ;OCL}}}
  1027.    ;OCL{{{  browser
  1028.    ( demand-load (
  1029.       ;OCL{{{  I-browser-area
  1030.       ( defmac I-browser-area
  1031.          ( I-default-win
  1032.            if >(ocl-arg-field(15) 0)
  1033.             ;OCL{{{  use win
  1034.             ( set I-ywin 2
  1035.               write-area I-menu-xwin I-ywin ( "Browser )
  1036.               set I-xwin 57
  1037.               I-center-xoff
  1038.               set I-ywin 3
  1039.               write-area I-xwin I-ywin ( "Move "( "Up/Down ") "  "  "Enter "( "Return ") "  "  "Exit "( "Backspace/Delete ") "  "  "Quit )
  1040.             )
  1041.             ;OCL}}}
  1042.            else
  1043.             ;OCL{{{  use mode
  1044.             ( set-user-mode I-XS-BROWSE )
  1045.             ;OCL}}}
  1046.            fi
  1047.          )
  1048.       )
  1049.       ;OCL}}}
  1050.       ;OCL{{{  I-browser
  1051.       ( deffun I-browser
  1052.          ( message "[loading]
  1053.            screen-off
  1054.            I-check-arg
  1055.            I-Browser
  1056.            I-browser-area
  1057.            set I-op 3
  1058.            read-file
  1059.               if I-arg-file-set
  1060.                ( get-history I-arg-file 0 )
  1061.               else
  1062.                ( default-browser-file )
  1063.               fi
  1064.               newline-and-indent
  1065.            screen-on
  1066.            message "[formatting]
  1067.            screen-off
  1068.            no-overstrike
  1069.            screen-on
  1070.            redraw-display
  1071.          )
  1072.       )
  1073.       ;OCL}}}
  1074.       ;OCL{{{  I-quit-browser
  1075.       ( deffun I-quit-browser
  1076.          ( reset-user-mode I-ENT
  1077.            I-re-enter-main
  1078.            I-main-reread
  1079.          )
  1080.       )
  1081.       ;OCL}}}
  1082.       ;OCL{{{  I-info-enter
  1083.       ( deffun I-info-enter
  1084.          ( if or(test-fold-line test-filed)
  1085.             ( message "[loading]
  1086.               ;OCL{{{  clear last-message-memory
  1087.               if
  1088.                  or
  1089.                   ( last-message M_NO_TEXT
  1090.                     last-message M_NO_ENTER_LIST_FF
  1091.                     last-message M_CANTOPEN
  1092.                   )
  1093.                ()
  1094.               fi
  1095.               ;OCL}}}
  1096.               screen-off
  1097.               enter-fold
  1098.               if
  1099.                ;OCL{{{  failed
  1100.                  or
  1101.                   ( last-message M_NO_TEXT
  1102.                     last-message M_NO_ENTER_LIST_FF
  1103.                     last-message M_CANTOPEN
  1104.                   )
  1105.                ;OCL}}}
  1106.                ;OCL{{{  message
  1107.                ( screen-on
  1108.                  redraw-display
  1109.                  message ( "[ "Currently "  "not "  "available! "] )
  1110.                )
  1111.                ;OCL}}}
  1112.               else
  1113.                ;OCL{{{  count enter
  1114.                ( set I-entered-filed +(I-entered-filed 1)
  1115.                  set-numbered-user-mode I-ENT I-entered-filed
  1116.                  delete-mode-view
  1117.                  delete-mode-hash-shift
  1118.                  set-file-unchanged
  1119.                  if =(set-enter 0)
  1120.                   ( screen-on
  1121.                     message "[formating]
  1122.                     screen-off
  1123.                     no-overstrike
  1124.                   )
  1125.                  fi
  1126.                  screen-on
  1127.                  redraw-display
  1128.                  message ()
  1129.                )
  1130.                ;OCL}}}
  1131.               fi
  1132.             )
  1133.            fi
  1134.          )
  1135.       )
  1136.       ;OCL}}}
  1137.       ;OCL{{{  I-info-exit
  1138.       ;OCL{{{  open2enter
  1139.       ( defmac open2enter
  1140.          ( local
  1141.             ( ocl-argument )
  1142.             ( if last-message M_TOP () fi
  1143.               if last-message M_USE_EXIT () fi
  1144.               set ocl-argument store-line
  1145.               close-fold
  1146.               if not(or(last-message M_TOP last-message M_USE_EXIT))
  1147.                ( open2enter
  1148.                  enter-fold
  1149.                  while <>(store-line ocl-argument)
  1150.                   ( next-line )
  1151.                )
  1152.               fi
  1153.             )
  1154.          )
  1155.       )
  1156.       ;OCL}}}
  1157.       ( deffun I-info-exit
  1158.          ( if I-entered-filed
  1159.             ( screen-off
  1160.               set I-entered-filed -(I-entered-filed 1)
  1161.               exit-fold
  1162.               if not(I-entered-filed)
  1163.                ( reset-user-mode I-ENT )
  1164.               else
  1165.                ( set-numbered-user-mode I-ENT I-entered-filed )
  1166.               fi
  1167.               open2enter
  1168.               screen-on
  1169.               redraw-display
  1170.             )
  1171.            fi
  1172.          )
  1173.       )
  1174.       ;OCL}}}
  1175.    ) )
  1176.    ;OCL}}}
  1177.    ;OCL{{{  startup
  1178.    ;OCL{{{  I-startup-read
  1179.    ( deffun I-startup-read
  1180.       (
  1181.         ;OCL{{{  get EDIT_CMD
  1182.         set I-edit-extern true
  1183.         history-edit I-edit-cmd ()
  1184.            get-edit-cmd-var
  1185.            if
  1186.             ;OCL{{{  end of echo and default or not used
  1187.               pre
  1188.                ( beginning-of-line
  1189.                  next-non-space-on-line
  1190.                )
  1191.                  or
  1192.                   ( test-end-line
  1193.                     test-str "default
  1194.                   )
  1195.             ;OCL}}}
  1196.             ;OCL{{{  clear cmd, use default
  1197.             ( beginning-of-line
  1198.               delete-to-end-of-line
  1199.               set I-edit-extern false
  1200.             )
  1201.             ;OCL}}}
  1202.            fi
  1203.            newline-and-indent
  1204.         ;OCL}}}
  1205.         ;OCL{{{  get NN_CMD
  1206.         history-edit I-nn-cmd ()
  1207.            get-nn-cmd-var
  1208.            if test-begin-line
  1209.             ( nn-cmd-def )
  1210.            fi
  1211.            newline-and-indent
  1212.         ;OCL}}}
  1213.       )
  1214.    )
  1215.    ;OCL}}}
  1216.    ;OCL{{{  I-startup
  1217.    ( deffun I-startup
  1218.       ( if I-edit-extern
  1219.          ( message ( "[ "Editor "  "is "  history I-edit-cmd "] ) )
  1220.         else
  1221.          ( message ( "[ "Editor "  "is "  "ModeOri "] ) )
  1222.         fi
  1223.       )
  1224.    )
  1225.    ;OCL}}}
  1226.    ;OCL}}}
  1227.    ;OCL{{{  I-restart-shell
  1228.    ( deffun I-restart-shell
  1229.       ( case
  1230.          ;OCL{{{  restart main-menu
  1231.          ( =(I-op 0)
  1232.             ( case
  1233.                ;OCL{{{  normal file at startup -> call editor
  1234.                ( =(file-type 0)
  1235.                  ( set I-op 1
  1236.                    if I-edit-extern
  1237.                     ;OCL{{{  call external editor
  1238.                     ( screen-off
  1239.                       history-edit-filename I-arg-file ()
  1240.                          newline-and-indent
  1241.                       screen-on
  1242.                       I-msg-extern-edit
  1243.                       screen-off
  1244.                       local
  1245.                        ( force-bourne-shell )
  1246.                        ( set force-bourne-shell true
  1247.                          shell-command
  1248.                             get-history I-edit-cmd 0
  1249.                             "  ;
  1250.                             get-history I-arg-file 0
  1251.                             newline-and-indent
  1252.                        )
  1253.                       newline-and-indent
  1254.                       screen-on
  1255.                     )
  1256.                     ;OCL}}}
  1257.                    else
  1258.                     ;OCL{{{  switch to edit
  1259.                     ( history-edit I-menu-directory ()
  1260.                          ".
  1261.                          newline-and-indent
  1262.                       end-shell-mode
  1263.                       return-from-macro
  1264.                     )
  1265.                     ;OCL}}}
  1266.                    fi
  1267.                  )
  1268.                )
  1269.                ;OCL}}}
  1270.                ;OCL{{{  directory file at startup -> use this in menu
  1271.                ( >(file-type 0)
  1272.                  ( history-edit-filename I-menu-directory ()
  1273.                       newline-and-indent
  1274.                  )
  1275.                )
  1276.                ;OCL}}}
  1277.               esac
  1278.               ;OCL{{{  start menu with default or last value
  1279.               I-start-main
  1280.               ;OCL}}}
  1281.             )
  1282.          )
  1283.          ;OCL}}}
  1284.          ;OCL{{{  came from editor -> restart main-menu
  1285.          (=(I-op 1)
  1286.            ( set I-op 0
  1287.              I-start-main
  1288.            )
  1289.          )
  1290.          ;OCL}}}
  1291.         esac
  1292.       )
  1293.    )
  1294.    ;OCL}}}
  1295.    ;OCL{{{  begin-shell-mode
  1296.    ( deffun begin-shell-mode
  1297.       ( end-modeori
  1298.         set I-hash counter test-hash-shift
  1299.         I-restart-shell
  1300.       )
  1301.    )
  1302.    ;OCL}}}
  1303.    ;OCL{{{  end-shell-mode
  1304.    ( deffun end-shell-mode
  1305.       ( reset-user-mode I-ENT
  1306.         if I-hash ( add-mode-hash-shift ) else ( delete-mode-hash-shift ) fi
  1307.         set-file-unchanged
  1308.         if >(ocl-arg-field(15) 0)
  1309.          ;OCL{{{  use area for QE-user-help
  1310.          ( set-area 5
  1311.            ;OCL{{{  write centered mode name
  1312.            set I-xwin 22
  1313.            I-center-xoff
  1314.            set I-ywin 2
  1315.            write-area I-xwin I-ywin ( "ModeOriShell-Editor )
  1316.            ;OCL}}}
  1317.            ;OCL{{{  write help for save/quit/open/close
  1318.            set I-xwin 72
  1319.            I-center-xoff
  1320.            set I-ywin 3
  1321.            write-area I-xwin I-ywin
  1322.             (          "Save: "  "esc "  "s "  "a
  1323.               "  "  "  "Quit: "  "esc "  "q "  "u
  1324.               "  "  "  "Open "  "fold: "  "esc "  "o "  "p
  1325.               "  "  "  "Close "  "fold: "  "esc "  "c "  "l
  1326.             )
  1327.            ;OCL}}}
  1328.            ;OCL{{{  write ( esc h b  for list of keys ) at left border
  1329.            set I-xwin 6
  1330.            set I-ywin 5
  1331.            write-area I-xwin I-ywin ( "( "  "esc "  "h "  "b "  "  "for "  "list "  "of "  "keys "  ") )
  1332.            ;OCL}}}
  1333.            ;OCL{{{  write ( esc i f for info ) at right border
  1334.            @if-using not( NO-HELP-BROWSER )
  1335.               set I-xwin -(screen-width 25)
  1336.               if <=(I-xwin 36)
  1337.                ( set I-xwin 36 )
  1338.               fi
  1339.               write-area I-xwin I-ywin ( "( "  "esc "  "i "  "f "  "  "for "  "info "  ") )
  1340.            @fi
  1341.            ;OCL}}}
  1342.            ;OCL{{{  write space at end of line to force inverse line!
  1343.            set I-xwin +(I-xwin screen-width)
  1344.            write-area I-xwin I-ywin ( "  )
  1345.            ;OCL}}}
  1346.          )
  1347.          ;OCL}}}
  1348.         else
  1349.          ;OCL{{{  no use of modes
  1350.          ( set-area 0
  1351.            I-clear-user-modes
  1352.            set-user-mode I-XS-EDIT
  1353.          )
  1354.          ;OCL}}}
  1355.         fi
  1356.         begin-modeori
  1357.       )
  1358.    )
  1359.    ;OCL}}}
  1360.    ;OCL{{{  shell-mouse
  1361.    @if-using (MOUSY)
  1362.       ( deffun ( cmd ) shell-mouse
  1363.          ( case
  1364.             ;OCL{{{  outside -> nop
  1365.             ( mouse-outside ( ) )
  1366.             ;OCL}}}
  1367.             ;OCL{{{  browser mouse handling
  1368.             ( =(I-op 3)
  1369.               ( I-go-mouse
  1370.                 case
  1371.                  ( =(cmd 1) ( I-info-enter ) )
  1372.                  ( =(cmd -1) ( I-info-exit ) )
  1373.                 esac
  1374.               )
  1375.             )
  1376.             ;OCL}}}
  1377.             ;OCL{{{  main-menu/file-menu -> go and open/nop/close
  1378.             ( or(=(I-op 0) =(I-op 2))
  1379.               ( set ocl-argument mouse-go-y
  1380.                 I-go-mouse
  1381.                 case
  1382.                  ;OCL{{{  open or call
  1383.                  ( =(cmd 1)
  1384.                     ( case
  1385.                        ;OCL{{{  not moved and main menu -> action select
  1386.                        ( and(=(ocl-argument 0) =(I-op 0))
  1387.                           ( I-action-select
  1388.                             return-from-macro
  1389.                           )
  1390.                        )
  1391.                        ;OCL}}}
  1392.                       default
  1393.                        ;OCL{{{  fold -> open
  1394.                        ( open-fold )
  1395.                        ;OCL}}}
  1396.                       esac
  1397.                     )
  1398.                  )
  1399.                  ;OCL}}}
  1400.                  ;OCL{{{  close fold
  1401.                  ( =(cmd -1) ( I-close-fold ) )
  1402.                  ;OCL}}}
  1403.                 esac
  1404.               )
  1405.             )
  1406.             ;OCL}}}
  1407.            default
  1408.             ;OCL{{{  go to position
  1409.             ( I-go-mouse )
  1410.             ;OCL}}}
  1411.            esac
  1412.            message ()
  1413.          )
  1414.       )
  1415.    @fi
  1416.    ;OCL}}}
  1417.    ;OCL{{{  hooks
  1418.    ;OCL{{{  I-prompt-in
  1419.    ( deffun I-prompt-in ( para ) )
  1420.    ;OCL}}}
  1421.    ;OCL{{{  I-prompt-out
  1422.    ( deffun I-prompt-out
  1423.       ( case
  1424.          ( =(I-op 2) ( I-File-Menu ) )
  1425.          ( =(I-op 3) ( I-Browser ) )
  1426.         default
  1427.          ( I-Main-Menu )
  1428.         esac
  1429.       )
  1430.    )
  1431.    ;OCL}}}
  1432.    ;OCL{{{  I-dummy-macro
  1433.    ( deffun I-dummy-macro ())
  1434.    ;OCL}}}
  1435.    ;OCL{{{  I-crash
  1436.    ( defmac I-crash ( set-file-unchanged I-prompt-out ))
  1437.    ;OCL}}}
  1438.    ;OCL{{{  I-key-not-bound
  1439.    ( deffun I-key-not-bound ( I-crash ) )
  1440.    ;OCL}}}
  1441.    ;OCL{{{  I-abort-hook
  1442.    ( deffun I-abort-hook
  1443.       ( case
  1444.         esac
  1445.         set I-op 1
  1446.         set-file-unchanged
  1447.         I-restart-shell
  1448.       )
  1449.    )
  1450.    ;OCL}}}
  1451.    ;OCL{{{  I-view-macro
  1452.    ( deffun I-view-macro ( I-crash ) )
  1453.    ;OCL}}}
  1454.    ;OCL}}}
  1455.    ;OCL}}}
  1456.    ;OCL{{{  undeclares
  1457.    ( undeclare
  1458.       ( I-history-edit-filename
  1459.         I-clear-user-modes
  1460.         I-check-arg
  1461.         I-prompt-for-file
  1462.         I-main-area
  1463.         I-start-main
  1464.         I-re-enter-main
  1465.         I-main-reread
  1466.         I-file-area
  1467.         I-copy-or-move-file
  1468.         I-browser-area
  1469.         I-restart-shell
  1470.         I-dummy-macro
  1471.         I-crash
  1472.         default-browser-file
  1473.         default-menu-file
  1474.         default-edit-file
  1475.         cp-cmd
  1476.         mv-cmd
  1477.         rm-cmd
  1478.         I-op
  1479.         I-menu-xwin
  1480.         I-xwin
  1481.         I-ywin
  1482.         I-entered-filed
  1483.         I-hash
  1484.         I-arg-file-set
  1485.         I-selected
  1486.         I-help
  1487.       )
  1488.    )
  1489.    ;OCL}}}
  1490.    ;OCL{{{  redefine exits for shell
  1491.    ;OCL{{{  exit-buffer
  1492.    ( defmac exit-buffer- ( exit-buffer ) )
  1493.    ( undeclare ( exit-buffer ) )
  1494.    ( deffun exit-buffer
  1495.       ( if and(ocl-arg-field(15) =(used-buffers 1) not(in-prompt))
  1496.          ( if test-file-changed
  1497.             ( para
  1498.               prompt-counter ocl-argument ( M_CHANGED_LEAVE "  "? "  )
  1499.               edit
  1500.               if not(ocl-argument)
  1501.                ( return-from-macro )
  1502.               fi
  1503.               set-file-unchanged
  1504.             )
  1505.            fi
  1506.            begin-shell-mode
  1507.            return-from-macro
  1508.          )
  1509.         fi
  1510.         exit-buffer-
  1511.       )
  1512.    )
  1513.    ( undeclare ( exit-buffer- ) )
  1514.    ;OCL}}}
  1515.    ;OCL{{{  exit-origami
  1516.    ( deffun shell-exit-origami
  1517.       ( case
  1518.          ;OCL{{{  shell used: leave additional unchanged buffer and return to shell
  1519.          ( and(ocl-arg-field(15) not(in-prompt))
  1520.             ( while <>(used-buffers 1)
  1521.                ( if test-file-changed
  1522.                   ( message ( "[ "file "  "changed "] )
  1523.                     return-from-macro
  1524.                   )
  1525.                  fi
  1526.                  exit-buffer
  1527.                )
  1528.               if test-file-changed
  1529.                ( message ( "[ "file "  "changed "]  )
  1530.                  return-from-macro
  1531.                )
  1532.               fi
  1533.               exit-buffer
  1534.             )
  1535.          )
  1536.          ;OCL}}}
  1537.         default
  1538.          ( exit-origami )
  1539.         esac
  1540.       )
  1541.    )
  1542.    ( undeclare ( exit-origami ) )
  1543.    ( defmac exit-origami ( shell-exit-origami ) )
  1544.    ;OCL}}}
  1545.    ;OCL{{{  save-and-exit-buffer
  1546.    ( defmac save-and-exit-buffer- ( save-and-exit-buffer ) )
  1547.    ( undeclare ( save-and-exit-buffer ) )
  1548.    ( deffun save-and-exit-buffer
  1549.       ( if and(ocl-arg-field(15) =(used-buffers 1) not(in-prompt))
  1550.          ( save-file
  1551.            if test-file-changed
  1552.             ( message ( "[File "  "changed "!] )
  1553.               return-from-macro
  1554.             )
  1555.            else
  1556.             ( begin-shell-mode
  1557.               return-from-macro
  1558.             )
  1559.            fi
  1560.          )
  1561.         fi
  1562.         save-and-exit-buffer-
  1563.       )
  1564.    )
  1565.    ( undeclare ( save-and-exit-buffer- ) )
  1566.    ;OCL}}}
  1567.    ;OCL}}}
  1568. @fi
  1569. ;OCL}}}
  1570. ;OCL{{{  edt simulation
  1571. @if-using ( SUNEDT )
  1572.    ( demand-load (
  1573.       ;OCL{{{  EDT-find-direction
  1574.       ( deffun EDT-find-direction
  1575.          ( if EDT-move-back ( search-reverse ) else ( search-forward ) fi )
  1576.       )
  1577.       ;OCL}}}
  1578.       ;OCL{{{  EDT-find-next-direction
  1579.       ( deffun EDT-find-next-direction
  1580.          ( EDT-find-direction
  1581.            previous-line
  1582.            newline-and-indent
  1583.          )
  1584.       )
  1585.       ;OCL}}}
  1586.       ;OCL{{{  EDT-page-begin
  1587.       ( deffun EDT-page-begin
  1588.          ( while >(cursor-level 2)
  1589.             ( previous-line )
  1590.          )
  1591.       )
  1592.       ;OCL}}}
  1593.       ;OCL{{{  EDT-section-move
  1594.       ( deffun EDT-section-move
  1595.          ( repeat 16 ( if EDT-move-back ( previous-line ) else ( next-line ) fi ) )
  1596.       )
  1597.       ;OCL}}}
  1598.       ;OCL{{{  EDT-set-direction-forward
  1599.       ( deffun EDT-set-direction-forward
  1600.          ( set EDT-move-back false
  1601.            reset-user-mode EDT-backup
  1602.          )
  1603.       )
  1604.       ;OCL}}}
  1605.       ;OCL{{{  EDT-set-direction-backward
  1606.       ( deffun EDT-set-direction-backward
  1607.          ( set EDT-move-back true
  1608.            set-user-mode EDT-backup
  1609.          )
  1610.       )
  1611.       ;OCL}}}
  1612.       ;OCL{{{  EDT-word-move
  1613.       ( deffun EDT-word-move
  1614.          ( if EDT-move-back ( backward-word ) else ( forward-word ) fi
  1615.          )
  1616.       )
  1617.       ;OCL}}}
  1618.       ;OCL{{{  EDT-char-move
  1619.       ( deffun EDT-char-move
  1620.          ( if EDT-move-back ( backward-character ) else ( forward-character ) fi
  1621.          )
  1622.       )
  1623.       ;OCL}}}
  1624.       ;OCL{{{  EDT-clear-kill
  1625.       ;OCL{{{  EDT-clear-kill-rec
  1626.       ( deffun EDT-clear-kill-rec
  1627.          ( case
  1628.             ;OCL{{{  handle mode view first
  1629.             ( test-view
  1630.                ( delete-mode-view
  1631.                  EDT-clear-kill-rec
  1632.                  add-mode-view
  1633.                )
  1634.             )
  1635.             ;OCL}}}
  1636.             ;OCL{{{  handle start of filed fold
  1637.             ( test-top
  1638.                ( next-line
  1639.                  EDT-clear-kill-rec
  1640.                  previous-line
  1641.                )
  1642.             )
  1643.             ;OCL}}}
  1644.            default
  1645.             ;OCL{{{  clear the buffer
  1646.             ( insert-folded-kill-buffer
  1647.               delete-line
  1648.               pop-delete-buffer
  1649.             )
  1650.             ;OCL}}}
  1651.            esac
  1652.          )
  1653.       )
  1654.       ;OCL}}}
  1655.  
  1656.       ( deffun EDT-clear-kill
  1657.          ( if kill-count
  1658.             ( screen-off
  1659.               if test-file-changed
  1660.                ( EDT-clear-kill-rec )
  1661.               else
  1662.                ( EDT-clear-kill-rec
  1663.                  set-file-unchanged
  1664.                )
  1665.               fi
  1666.               screen-on
  1667.               redraw-display
  1668.             )
  1669.            fi
  1670.          )
  1671.       )
  1672.       ;OCL}}}
  1673.       ;OCL{{{  EDT-undelete-line
  1674.       ( deffun EDT-undelete-line
  1675.          ( if not(test-view)
  1676.             ( if last-message M_NO_UNDEL () fi
  1677.               if last-message M_ERR_PO () fi
  1678.               undo-delete-line
  1679.               if not(or(last-message M_NO_UNDEL last-message M_ERR_PO ))
  1680.                ( double-line
  1681.                  delete-line
  1682.                )
  1683.               fi
  1684.             )
  1685.            fi
  1686.          )
  1687.       )
  1688.       ;OCL}}}
  1689.       ;OCL{{{  EDT-quit-buffer
  1690.       ( deffun EDT-quit-buffer
  1691.          ( set-file-unchanged
  1692.            exit-buffer
  1693.          )
  1694.       )
  1695.       ;OCL}}}
  1696.       ;OCL{{{  EDT-exit-buffer
  1697.       ( defmac EDT-exit-buffer
  1698.          ( save-and-exit-buffer
  1699.          )
  1700.       )
  1701.       ;OCL}}}
  1702.       ;OCL{{{  EDT-toggle-mode-overwrite
  1703.       ( deffun EDT-toggle-mode-overwrite
  1704.          ( if test-overwrite
  1705.             ( delete-mode-overwrite )
  1706.            else
  1707.             ( add-mode-overwrite )
  1708.            fi
  1709.          )
  1710.       )
  1711.       ;OCL}}}
  1712.       ;OCL{{{  EDT-paste-and-rekill-line
  1713.       ( deffun EDT-paste-and-rekill-line
  1714.          ( if not(test-view)
  1715.             ( if last-message M_ERR_PO () fi
  1716.               if last-message M_NO_PICK () fi
  1717.               insert-folded-kill-buffer
  1718.               if not(or(last-message M_ERR_PO last-message M_NO_PICK) )
  1719.                ( enter-fold
  1720.                  while not(test-bottom)
  1721.                   ( copy-to-kill-buffer
  1722.                     next-line
  1723.                   )
  1724.                  exit-fold
  1725.                )
  1726.               fi
  1727.             )
  1728.            fi
  1729.          )
  1730.       )
  1731.       ;OCL}}}
  1732.       ;OCL{{{  EDT-replace-line-by-kill
  1733.       ( deffun EDT-replace-line-by-kill
  1734.          ( if not(test-view)
  1735.             ( if last-message M_NO_UNDEL () fi
  1736.               if last-message M_ERR_PO () fi
  1737.               undo-delete-line
  1738.               if not(last-message M_ERR_PO)
  1739.                ( if last-message M_NO_UNDEL
  1740.                   ( delete-line
  1741.                     EDT-paste-and-rekill-line
  1742.                   )
  1743.                  else
  1744.                   ( next-line
  1745.                     delete-line
  1746.                     previous-line
  1747.                     delete-line
  1748.                     EDT-paste-and-rekill-line
  1749.                   )
  1750.                  fi
  1751.                )
  1752.               fi
  1753.             )
  1754.            fi
  1755.          )
  1756.       )
  1757.       ;OCL}}}
  1758.       ;OCL{{{  EDT-clear-kill-and-cut-line
  1759.       ( deffun EDT-clear-kill-and-cut-line
  1760.          ( EDT-clear-kill
  1761.            copy-to-kill-buffer
  1762.          )
  1763.       )
  1764.       ;OCL}}}
  1765.       ;OCL{{{  EDT-toggle-case-char
  1766.       ( deffun EDT-toggle-case-char
  1767.          ( case-character-toggle
  1768.            forward-character
  1769.          )
  1770.       )
  1771.       ;OCL}}}
  1772.       ;OCL{{{  EDT-insert-number-char
  1773.       ( deffun EDT-insert-number-char
  1774.          ( para
  1775.            prompt-counter ocl-argument "Coding:
  1776.            insert-ascii ocl-argument
  1777.            edit
  1778.          )
  1779.       )
  1780.       ;OCL}}}
  1781.       ;OCL{{{  EDT-delete-to-beginning-of-line
  1782.       ( deffun EDT-delete-to-beginning-of-line
  1783.          ( if not(test-view)
  1784.             ( if last-message M_ERR_PO () fi
  1785.               local
  1786.                ()
  1787.                ( while >(store-pos 1)
  1788.                   ( backward-character
  1789.                     if not(test-end-line)
  1790.                      ( raw-delete-character
  1791.                        if last-message M_ERR_PO
  1792.                         ( forward-character
  1793.                           return-from-macro
  1794.                         )
  1795.                        fi
  1796.                      )
  1797.                     fi
  1798.                   )
  1799.                )
  1800.             )
  1801.            fi
  1802.          )
  1803.       )
  1804.       ;OCL}}}
  1805.       ;OCL{{{  EDT-undo-delete-line-unfolded-at-position
  1806.       ( deffun EDT-undo-delete-line-unfolded-at-position
  1807.          ( in-at-position(EDT-undelete-line) )
  1808.       )
  1809.       ;OCL}}}
  1810.       ;OCL{{{  EDT-clear-kill-and-cut-region
  1811.       ( deffun EDT-clear-kill-and-cut-region
  1812.          ( EDT-clear-kill
  1813.            copy-kill-mark-region
  1814.          )
  1815.       )
  1816.       ;OCL}}}
  1817.       ;OCL{{{  EDT-paste-and-rekill-region
  1818.       ;OCL{{{  EDT-paste-and-rekill-line
  1819.       ( deffun EDT-paste-and-rekill-line-move
  1820.          ( EDT-paste-and-rekill-line
  1821.            previous-line
  1822.          )
  1823.       )
  1824.       ;OCL}}}
  1825.  
  1826.       ( deffun EDT-paste-and-rekill-region
  1827.          ( in-at-position(EDT-paste-and-rekill-line-move) )
  1828.       )
  1829.       ;OCL}}}
  1830.       ;OCL{{{  EDT-replace-region-by-kill
  1831.       ( deffun EDT-replace-region-by-kill
  1832.          ( delete-mark-region
  1833.            switch-to-move-mode
  1834.            EDT-paste-and-rekill-region
  1835.          )
  1836.       )
  1837.       ;OCL}}}
  1838.    ) )
  1839. @fi
  1840. ;OCL}}}
  1841.